package com.zxy.salenet.web.mapper;

import com.zxy.salenet.web.pojo.SalenetIndent;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;
 /**
 *    SalenetIndentMapper。
     */
public interface SalenetIndentMapper extends Mapper<SalenetIndent> {

    /**
     * 添加购买到商品订单表
     * @param salenetIndent  商品订单表信息
     * @return
     */
    @Insert(value = "insert into salenet_indent values(default,#{indentId},#{indentUser},#{indentTimes},#{indentPayTimes},#{indentSendTimes},#{indentAddress},#{indentStatus},1,#{indentPrice},#{indentPayName},#{indentPayCount},#{indentName},${imgUrl})")
    Integer addIndent(SalenetIndent salenetIndent);

    /**
     * 修改显示状态
     * @param indentId
     * @return
     */
    @Update(value = "update salenet_indent set indent_life = 0 where indent_id = #{indentId}")
    Integer deleteByIndentId(@Param("indentId") Integer indentId);

    /**
     * 获取未删除信息
     * @return
     */
    @Select(value = "select * from salenet_indent where indent_life = 1 and indent_user = #{userId}")
    List<SalenetIndent> selectAllStatus(@Param("userId") Integer userId);

    @Select(value = "select indent_id from salenet_indent where indent_life = 1 and indent_user = #{userId} order by id DESC")
    List<Integer> selectIndentId(Integer userId);

    @Select(value = "select * from salenet_indent where indent_life = 1 and indent_id = #{indentId}")
    List<SalenetIndent> selectBuyIndentId(@Param("indentId") Integer indentEnty);
    /**
     * 完成
     */
}